package com.powernode.config;

import com.powernode.interceptor.CheckTokenInterceptor;
import com.powernode.vo.InterceptorRelease;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器,拦截的请求
 * 刘冠志
 * 2023/1/10
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private CheckTokenInterceptor checkTokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有除了/user/**
        registry.addInterceptor(checkTokenInterceptor).addPathPatterns(InterceptorRelease.CONSTRAINED)
                .excludePathPatterns(InterceptorRelease.RELEASE);
    }
}
